Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Jul 29, 2025

Track usage of custom commands vs mode switch commands

Summary

This PR implements telemetry tracking for slash command usage in the Roo Code extension to help understand how users interact with slash commands.

Changes

  • New telemetry event: Added SLASH_COMMAND_USED event type to track slash command usage
  • Command detection: Implemented regex-based slash command detection with pattern /(?:^|\s)(\/[a-zA-Z][a-zA-Z0-9_-]*)(?=\s|$)/gm
  • Command classification: Distinguishes between "mode_switch" commands (like /code, /debug) and "custom" commands
  • Integration: Added telemetry capture in user input processing flow in Task.ts
  • Comprehensive testing: Added test suites for both detection logic and telemetry integration

Files Modified

  • packages/types/src/telemetry.ts - Added new telemetry event type
  • packages/telemetry/src/TelemetryService.ts - Added captureSlashCommandUsed() method
  • src/core/task/Task.ts - Integrated slash command detection and telemetry capture
  • src/utils/slashCommandDetection.ts - New utility for detecting and classifying slash commands
  • Added comprehensive test coverage for all new functionality

Testing

  • ✅ All existing tests pass
  • ✅ New test suites with 19 total test cases
  • ✅ TypeScript compilation passes
  • ✅ Linting passes with no warnings
  • ✅ Covers edge cases like file paths, URLs, and invalid patterns

Usage Analytics

This will help track:

  • Which slash commands are most popular
  • Usage patterns between built-in mode commands vs custom commands
  • User engagement with the slash command feature

Important

Add telemetry tracking for slash command usage, distinguishing between custom and mode switch commands, with integration and testing across multiple files.

  • Telemetry:
    • Added SLASH_COMMAND_USED event type in telemetry.ts.
    • Implemented captureSlashCommandUsed() in TelemetryService.ts to log command usage.
  • Command Detection:
    • Added regex-based detection for slash commands in slashCommandDetection.ts.
    • Classifies commands as "mode_switch" or "custom".
  • Integration:
    • Integrated telemetry capture in Task.ts and ChatTextArea.tsx.
  • Testing:
    • Added test suite TelemetryService.slashCommands.test.ts with 19 test cases.
  • Misc:
    • Updated Task.ts to handle telemetry in user input processing.

This description was created by Ellipsis for 34b00c9. You can customize this summary. It will automatically update as commits are pushed.

@roomote roomote bot requested review from cte, jr and mrubens as code owners July 29, 2025 18:50
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 29, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roomote-agent instead of command detection, just track if they click on an option in the slash autocomplete or the zap menu

roomote[bot]

This comment was marked as outdated.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 29, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 31, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 31, 2025
daniel-lxs

This comment was marked as outdated.

Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jul 31, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 31, 2025
roomote and others added 2 commits October 20, 2025 11:51
- Add SLASH_COMMAND_USED telemetry event type
- Implement slash command detection with regex pattern matching
- Classify commands as mode_switch vs custom types
- Integrate telemetry capture in user input processing
- Add comprehensive test coverage for detection logic and telemetry
- Remove detectSlashCommands utility and its usage from Task.ts
- Add telemetry tracking to SlashCommandsList for popover clicks
- Add telemetry tracking to ChatTextArea for context menu selections
- Track both mode switches and custom commands with appropriate types
- Delete unused slashCommandDetection.ts and its tests
@hannesrudolph hannesrudolph force-pushed the feature/slash-command-telemetry branch from 451d328 to 34b00c9 Compare October 20, 2025 18:07
@roomote
Copy link
Author

roomote bot commented Oct 20, 2025

Code Review Summary

I've reviewed the telemetry implementation for slash command usage tracking. The PR has 3 issues that need to be addressed:

Issues Found

  • Incorrect command type value (line 306): Using "mode" instead of "mode_switch" - this doesn't match the TelemetryService.captureSlashCommandUsed() type signature
  • Missing taskId parameter (lines 305-308): First telemetry call is missing the required taskId property
  • Missing taskId parameter (lines 320-323): Second telemetry call is also missing the required taskId property

Required Changes

  1. Change commandType: "mode" to commandType: "mode_switch" on line 306
  2. Add taskId property to both telemetry capture calls - you'll need to access the current task ID from the extension state or context
  3. Ensure the telemetry client signature matches the backend TelemetryService.captureSlashCommandUsed(taskId, commandType, commandName) method

Context

The backend TelemetryService.captureSlashCommandUsed() expects three parameters:

  • taskId: string - The task ID where the command was used
  • commandType: "custom" | "mode_switch" - The type of command
  • commandName: string - The name of the command

The webview's telemetryClient.capture() is a lower-level method that doesn't enforce these parameters, which is why TypeScript isn't catching these issues.

if (type === ContextMenuOptionType.Mode && value) {
// Track telemetry for mode selection from context menu
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
commandType: "mode",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commandType value should be "mode_switch" not "mode" to match the type signature of TelemetryService.captureSlashCommandUsed(taskId, commandType: "custom" | "mode_switch", commandName). This mismatch will cause the telemetry data to be inconsistent with the intended classification of mode switch commands.

Comment on lines +305 to +308
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
commandType: "mode",
commandName: value,
})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The telemetry capture is missing the taskId property. According to the backend TelemetryService.captureSlashCommandUsed() signature and the telemetry schema, this event requires taskId, commandType, and commandName properties. The webview needs access to the current task ID to properly track slash command usage. Consider passing the task ID through the extension state or event context.

Comment on lines +320 to +323
telemetryClient.capture(TelemetryEventName.SLASH_COMMAND_USED, {
commandType: "custom",
commandName: value,
})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This telemetry capture is also missing the taskId property. The TelemetryService.captureSlashCommandUsed() method requires three parameters: taskId, commandType, and commandName. Without the task ID, the telemetry data won't be properly associated with the task context.

@hannesrudolph hannesrudolph moved this from PR [Needs Review] to PR [Needs Prelim Review] in Roo Code Roadmap Oct 20, 2025
@daniel-lxs
Copy link
Member

I don't think this is needed

@daniel-lxs daniel-lxs closed this Oct 22, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 22, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Oct 22, 2025
@daniel-lxs daniel-lxs deleted the feature/slash-command-telemetry branch October 22, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants